package com.better.common.amqp.receiver;

import com.better.common.amqp.listener.AbstractMessageListener;
import com.better.common.amqp.util.MQBusinessConstants;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.stereotype.Component;

/**
 * 用户信息消费，一个例子
 * Created by Administrator on 2018/1/10.
 */
/*@Component
@RabbitListener(queues = MQBusinessConstants.BUS_QUEUE)*/
public class UsermodelMessageListenter extends AbstractMessageListener {
    @RabbitHandler
    @Override
    public void receiveMessage(Message message, MessageConverter messageConverter) {
        Object bizObj = messageConverter.fromMessage(message);
        System.out.println(bizObj);
        throw  new RuntimeException("模拟异常");
        //System.out.println("获取到消息内容："+message.getBody().toString());
    }
}
